import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import cn.com.blackboard.DataModule4B2.util.DataSourceModel;

public class test {
	private static final Logger logger = LoggerFactory.getLogger(test.class);
	public static void main(String[] args) {
		String json = "[{\"K\":\"lineitem39876\",\"V\":\"finalTest\"},{\"K\":\"lineitem2\",\"V\":\"midTermTest\"},{\"K\":\"lineitem1\",\"V\":\"regularTest\"},{\"K\":\"lineitem8\",\"V\":\"attribute5\"},{\"K\":\"lineitem7\",\"V\":\"attribute4\"},{\"K\":\"lineitem6\",\"V\":\"attribute3\"},{\"K\":\"lineitem5\",\"V\":\"attribute2\"},{\"K\":\"lineitem4\",\"V\":\"attribute1\"}]";
		//String json = "{\"K\":\"lineitem39876\",\"V\":\"finalTest\"}";
		
		/*JSONArray myJsonArray = JSONArray.fromObject(json);
		String[] arr = {"11","22"};
		Condition condition = new Condition();
		condition.setAttrStr("attribute2".toUpperCase());
		condition.setOperStr(Condition.Operator.Equals.toString());
		condition.setValue("datasourcekey");
		condition.setIsImported("N");
		String conditionStr = Condition.RenderConditoin(condition);
		System.out.println(conditionStr);
		*/
		
		
		
		/*String prop = "TeacherCourseInfo.userId+CourseInfo.courseId+CourseInfo.attribute1";
		String[] operValue = prop.split("\\+");
		if(operValue.length<2){
			logger.info("commonConfig。courseIdAppender configuration error, please make sure the configuration file correct");
			logger.info("error");
		}			
		for(String entry:operValue){
			String[] keyValue = entry.split("\\.");
			if(keyValue.length!=2){
				logger.info("commonConfig。courseIdAppender configuration error, please make sure the configuration file correct");
				logger.info("error");
			}
			logger.info(keyValue[0]+"%%%%%%"+keyValue[1]);
		}*/
		
		/*HierarchicalQueryModel hierarchicalQueryModel = new HierarchicalQueryModel();
		hierarchicalQueryModel.setOnCondition("CourseInfo.courseId = TeacherCourseInfo.courseId");
		hierarchicalQueryModel.setTargetAttribute("CourseInfo.courseId");
		hierarchicalQueryModel.setSplitor("-");
		List<String> sourceAttributes = new ArrayList<String>();
		sourceAttributes.add("CourseInfo.courseId");
		sourceAttributes.add("TeacherCourseInfo。userId");
		sourceAttributes.add("CourseInfo.attribute1");
		hierarchicalQueryModel.setSourceAttributes(sourceAttributes);
		
		
		try {
			HierarchicalQueryLoader.hierarchicalQueryModel2XML(hierarchicalQueryModel);
		} catch (MarshalException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (ValidationException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		*/
		
		/*List<HierarchicalQueryModel> list = HierarchicalQueryLoader.getHierarchicalQueryModelList();
		for(HierarchicalQueryModel model:list){
			logger.info(model.getOnCondition());
			logger.info(model.getSplitor());
			logger.info(model.getTargetAttribute());
			for(String tmp:model.getSourceAttributes()){
				logger.info(tmp);
			}
			logger.info(model.getMainTable());
			logger.info(model.getSubTable());
		}*/
		
	/*	String aaa = "CourseInfo.userId";
		String bbb = "TeacherCourseInfo.userId";
		String regex = "^CourseInfo.*";
		logger.info("*"+aaa.matches(regex));
		if(aaa.matches(regex))
			aaa = aaa.replace("CourseInfo", "BB_COURSE_INFO");

		logger.info("*"+bbb.matches(regex));
		if(bbb.matches(regex))
			bbb = bbb.replace("CourseInfo", "BB_COURSE_INFO");
		logger.info(aaa);
		logger.info(bbb);*/
		
		/*MyBatisXMLModel model = HierarchicalQueryLoader.getMyBatisXMLModelByClsName(CourseInfo.class);

		logger.info("*****"+model.getMainTable());
		logger.info("*****"+model.getSubTable());
		logger.info("*****"+model.getOnCondition());
		logger.info("*****"+model.getFixedColList());*/
		
		/*BaseModel model = new CourseInfo();
		logger.info(model.getClass().getSimpleName());*/
		
		
		/*List<DataSourceModel> dataSourceModelList=DataSourceKeyUtil.getDataSourceModelList();
		for(DataSourceModel ds:dataSourceModelList){
			logger.info(ds.getBbClsName());
			logger.info(ds.getModelClsName());
			logger.info(ds.getRawSourceId());
			logger.info(ds.getSourceType().getValue());
			logger.info(ds.getRenderAttribute());
			logger.info(ds.getMapperAttribute());
		}*/
		/*SourceType[] types = DataSourceModel.SourceType.values();
		SourceType st1 = SourceType.RAWTYPE;
		for(SourceType st:types){
			logger.info(String.valueOf(st==st1));
		}*/
		/*String test = "course33787-2017-2018-02";
		Pattern pattern = Pattern.compile("(?<=-)(.*)");
		Matcher matcher = pattern.matcher(test);
		matcher.find();
		test = matcher.group();
		logger.info(test);
		Matcher matcher1 = pattern.matcher(test);
		while(matcher1.find())
            logger.info(matcher1.group().toString());*/
		
		//HierarchicalQueryLoader.getMyBatisXMLModelByClsName(CourseInfo.class);
		
		/*ExtentionModel em1 = new ExtentionModel();
		ExtentionModel em2 = new ExtentionModel();
		em1.setBbAttribute("");
		em1.setBbClsName("");
		em1.setModelAttribute("");
		em1.setModelClsName("");
		
		em2.setBbAttribute("1");
		em2.setBbClsName("2");
		em2.setModelAttribute("3");
		em2.setModelClsName(null);
		
		List<ExtentionModel> list = ExtentionAttributeUtil.getExtentionList();
		
		for(int i = 0; i < 20; i++){
			list.add(em1);
		}
		
		ExtentionAttributeUtil.setAndPersistExtentionList(list);*/
		
		DataSourceModel sdModel = new DataSourceModel();
		logger.info(sdModel.getSourceType().getValue());
	}

}
